package com.piesat.quake.business.station.api;

import com.piesat.common.vo.ResultVO;
import com.piesat.quake.business.station.service.DataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;


@Api(value = "仪器：地震仪数据", tags = "仪器：地震仪数据")
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/data")
public class DataController {

    private final DataService dataService;

    @ApiOperation(value = "根据时间范围查询特征值列表", notes = "根据时间范围查询特征值列表")
    @GetMapping(value = "/fd/list")
    public ResultVO findFdDataList(String id, Long startTime, Long endTime, Integer rate) {
        return ResultVO.success(dataService.findFdDataList(id, startTime, endTime, rate));
    }

    @ApiOperation(value = "根据时间范围查询实时值列表", notes = "根据时间范围查询实时值列表")
    @GetMapping(value = "/wc/list")
    public ResultVO findWcDataList(String id, Long startTime, Long endTime, Integer rate) {
        return ResultVO.success(dataService.findWcDataList(id, startTime, endTime, rate));
    }

    @ApiOperation(value = "开启实时", notes = "开启实时")
    @PostMapping(value = "/real/start")
    public ResultVO startReal(String id) {
        dataService.startReal(id);
        return ResultVO.success();
    }

    @ApiOperation(value = "停止实时", notes = "停止实时")
    @PostMapping(value = "/real/stop")
    public ResultVO stopReal(String id) {
        dataService.stopReal(id);
        return ResultVO.success();
    }

    @ApiOperation(value = "开启FTP", notes = "开启FTP")
    @PostMapping(value = "/ftp/start")
    public ResultVO startFtp(String id) {
        dataService.startFtp(id);
        return ResultVO.success();
    }

    @ApiOperation(value = "停止FTP", notes = "停止FTP")
    @PostMapping(value = "/ftp/stop")
    public ResultVO stopFtp(String id) {
        dataService.stopFtp(id);
        return ResultVO.success();
    }

    @ApiOperation(value = "重启", notes = "重启")
    @PostMapping(value = "/reboot")
    public ResultVO reboot(String id) {
        dataService.reboot(id);
        return ResultVO.success();
    }

    @ApiOperation(value = "查询最新的count条地震事件", notes = "查询最新的count条地震事件")
    @GetMapping(value = "/ti/list")
    public ResultVO findTiDataList(@RequestParam(value = "count", required = true) int count, @RequestParam(value = "id", required = false) String id) {
        return ResultVO.success(dataService.findTiDataList(count, id));
    }
}
